package com.geeker.common.util;

import com.geeker.common.entity.DefaultPage;
import com.mybatisflex.core.paginate.Page;

public class PageUtil {

    public static final Integer DEFAULT_PAGE_NUM = 1;

    public static final Integer DEFAULT_PAGE_SIZE = 10;

    public static <T> Page<T> getPage(DefaultPage defaultPage) {
        Integer pageNum = defaultPage.getCurrent();
        Integer numPerPage = defaultPage.getSize();
        if(pageNum == null) pageNum = DEFAULT_PAGE_NUM;
        if(numPerPage == null) numPerPage = DEFAULT_PAGE_SIZE;
        return new Page<>(pageNum, numPerPage);
    }
}
